package com.jl.sms.userdata;

import com.jl.card.JL;
import com.jl.util.CodeUtil;
import com.jl.util.HexUtil;

public class TextShortMessage implements ShortMessage {

	private byte[] data;

	public TextShortMessage(int type, String text) {
		switch (type) {
		case JL.CODE_ASCII:
			data = CodeUtil.getAnsi(text);
			break;
		case JL.CODE_BIT7:
			data = CodeUtil.get7Bit(text);
			break;
		case JL.CODE_HEX:
			data = HexUtil.parseHexToByteArray(text);
			break;
		case JL.CODE_UCS2:
			data = CodeUtil.getUnicode(text);
			break;
		default:
			break;
		}
	}

	@Override
	public byte[] value() {
		return this.data;
	}

	@Override
	public int headerLength() {
		return 0;
	}

}
